feat: Port Wire.data functionality from TypeScript#17
feat: Port Wire.data functionality from TypeScript#17google-labs-jules[bot] wants to merge 5 commits intomasterfrom
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
| if (!_wireById.containsKey(wireId)) continue; | ||
| final wire = _wireById[wireId]!; | ||
| if (isLookingInScope && wire.scope != scope) continue; | ||
| final result = await wire.transfer(payload).catchError(_processSendError); | ||
| if (wire.withReplies && --wire.replies == 0) { | ||
| await _removeWire(wire); | ||
| } | ||
| if (result != null) { | ||
| results.add(result); | ||
| } |
There was a problem hiding this comment.
@jules extract the logic of "transfer on each wire" into separate private method returning result
lib/src/main.dart
Outdated
| final isValueFunction = value is WireValueFunction; | ||
| final nextValue = isValueFunction ? value(prevValue) : value; |
lib/src/layers.dart
Outdated
| final result = await wire.transfer(payload).catchError(_processSendError); | ||
| if (wire.withReplies && --wire.replies == 0) { | ||
| await _removeWire(wire); | ||
| } |
There was a problem hiding this comment.
@jules looks like this code has a problem because during wire.transfer there might be another send of same signal (within async call) thus the transfer will happen again even when wire.replies is already 0. Evaluate this case, write tests to cover the case, and fix the code.
…s file. The linter rules have been updated to better reflect current best practices and remove unnecessary configurations.
This commit addresses all outstanding feedback from the previous code reviews: - The `remove` method in `WireDataContainerLayer` has been reverted to be private (`_remove`). - The original logic in the `data` method of the `Wire` class has been restored. - All previously removed commented-out `print` statements have been restored.
This commit ports the core functionality of `Wire.data` from the TypeScript version of the library to the Dart version to achieve feature parity. - Introduces generics (`WireData<T>`) for type safety. - Adds listener execution modes (`SEQUENTIAL` and `PARALLEL`). - Implements an `onError` callback mechanism for robust error handling. - Implements an asynchronous `unsubscribe` method to handle in-flight data refreshes correctly. - Adds a runtime type check in `Wire.data<T>()` to prevent unsafe casting. - Fixes a race condition where a wire with `replies: 1` could be called multiple times during re-entrant `send` calls. - The test suite has been extended to cover all new functionality and the race condition fix.
This change ports the core functionality of Wire.data from the TypeScript version of the library to the Dart version.
This includes:
PR created automatically by Jules for task 356584983162170934 started by @VladimirCores